#include "stdio.h"
#include "stdlib.h"

void swap(int*, int*);
void swap_xor(int*, int*);

// the main function
int main()
{
    int iVal1 = 5, iVal2 = 6; // declare variables

    printf("before: a = %d, b = %d\n", iVal1, iVal2);

    // call function to do swap
    swap_xor(&iVal1, &iVal2);
    
    printf("after: a = %d, b = %d\n", iVal1, iVal2);

    return 0;
}

void swap(int *px, int *py)
{
    int temp;

    temp = *px;
    *px = *py;
    *py = temp;
}

void swap_xor(int *px, int *py)
{
    *px = *px ^ *py;
    *py = *px ^ *py;
    *px = *px ^ *py;
}
